<?php
class UserIdentity extends CUserIdentity
{
private $ id;
public function authenticate()
{
$username=strtolower($this->username);
$user=User::model()->find(’LOWER(username)=?’,array($username));
if($user===null)
$this->errorCode=self::ERROR USERNAME INVALID;
else if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR PASSWORD INVALID;
else
{
$this-> id=$user->id;
$this->username=$user->username;
$this->errorCode=self::ERROR NONE;
}
return $this->errorCode==self::ERROR NONE;
}
public function getId()
{
return $this-> id;
}
}